package com.touna.service.impl;

import com.touna.bean.VoiceRecord;
import com.touna.com.touna.service.VoiceService;
import com.touna.mapper.voice.VoiceRecordMapper;
import com.touna.tools.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by xl on 2018/2/11.
 */
@Service
public class VoiceServiceImpl implements VoiceService {

    @Autowired
    VoiceRecordMapper voiceRecordMapper;

    @Override
    public Page qureyVoices(Page page,VoiceRecord record) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("pageIndex",page.getPageIndex());
        map.put("pageSize",page.getPageSize());
        map.put("wordType",record.getWordType());
        map.put("classTypeName",record.getClassTypeName());
        map.put("chineseName",record.getChineseName());

        page.setRows(voiceRecordMapper.qureyVoices(map));
        page.setTotal(totalVoice());
        return  page;
    }

    private int totalVoice() {
        return voiceRecordMapper.totalVoice();
    }

}
